/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package modele;

import java.util.Collection;
import java.util.HashSet;
import java.util.TreeSet;

/**
 *
 * @author wkhim
 */
public class Dep implements Comparable<Dep> {

    private String num;
    private Collection<Med> lesMeds = new TreeSet<Med>();

    public Dep(String num) {
        this.num = num;
    }

    public Collection<Med> getLesMeds() {
        return lesMeds;
    }

    public String getNum() {
        return num;
    }

    @Override
    public int compareTo(Dep d) {
        return num.compareTo(d.num);
    }

    public void ajouterMed(Med unMed) {
        lesMeds.add(unMed);
    }

    public Collection<Med> getLesMed(String unNom) {
        Collection<Med> medRecherche = new HashSet<Med>();
        for (Med unMed : lesMeds) {
            if (unMed.getNom().startsWith(firstLetterCaps(unNom))) {
                medRecherche.add(unMed);
            }
        }
        return medRecherche;
    }

    static public String firstLetterCaps(String data) {
        String firstLetter = data.substring(0, 1).toUpperCase();
        String restLetters = data.substring(1).toLowerCase();
        return firstLetter + restLetters;
    }
}
